package com.hua.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hua.lease.model.entity.SystemPost;
import com.hua.lease.model.entity.SystemUser;
import com.hua.lease.web.admin.mapper.SystemPostMapper;
import com.hua.lease.web.admin.mapper.SystemUserMapper;
import com.hua.lease.web.admin.service.SystemUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hua.lease.web.admin.vo.system.user.SystemUserItemVo;
import com.hua.lease.web.admin.vo.system.user.SystemUserQueryVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liubo
 * @description 针对表【system_user(员工信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser>
        implements SystemUserService {

	@Autowired
	protected SystemUserMapper systemUserMapper;

	@Autowired
	protected SystemPostMapper systemPostMapper;

	@Override
	public IPage<SystemUserItemVo> pageSystemUserByQuery(IPage<SystemUser> page, SystemUserQueryVo queryVo) {
		return systemUserMapper.pageSystemUserByQuery(page, queryVo);
	}

	@Override
	public SystemUserItemVo getSystemUserById(Long id) {
		// 查询用户信息
		SystemUser systemUser = systemUserMapper.selectById(id);
		// 查询岗位信息
		SystemPost systemPost = systemPostMapper.selectById(systemUser.getPostId());
		// 封装岗位信息
		SystemUserItemVo systemUserItemVo = new SystemUserItemVo();
		BeanUtils.copyProperties(systemPost, systemUserItemVo);
		systemUserItemVo.setPostName(systemUserItemVo.getPostName());

		return systemUserItemVo;
	}
}




